package com.software.comment.utils;

import com.github.houbb.sensitive.word.bs.SensitiveWordBs;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;


/**
 * @author lj20050120
 */
@Component
public class SensitiveWordUtil {

    @Resource
    private SensitiveWordBs sensitiveWordBs;

    /**
     * 判断是否包含敏感词
     * @param text 待检测文本
     * @return 是否包含
     */
    public boolean contains(String text) {
        return sensitiveWordBs.contains(text);
    }
    /**
     * 替换敏感词
     * @param text 待替换文本
     * @param replaceChar 替换符
     * @return 替换后的文本
     */
    public String replace(String text, char replaceChar) {
        return sensitiveWordBs.replace(text, replaceChar);
    }
    /**
     * 替换敏感词
     * @param text 待替换文本
     * @return 替换后的文本
     */
    public String replace(String text) {
        return sensitiveWordBs.replace(text);
    }

}